.\"	$OpenBSD: update-patches.1,v 1.6 2017/05/26 10:50:28 espie Exp $
.\"
.\" Copyright (c) 2010 Marc Espie <espie@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: May 26 2017 $
.Dt UPDATE-PATCHES 1
.Os
.Sh NAME
.Nm update-patches
.Nd create or update patches for a given port.
.Sh SYNOPSIS
.Nm update-patches
.Sh DESCRIPTION
.Nm
is a helper script for the target
.Ar update-patches
in
.Xr bsd.port.mk 5 .
It takes no argument, but uses quite a few environment variables as
implicit parameters.
.Pp
.Nm
looks under
.Ev WRKDIST
for patched files.
Those are files with extension
.Ev PATCHORIG ,
except for those matching also
.Ev DISTORIG .
.Pp
Once those files are found, they are matched against the contents of
directory
.Ev PATCHDIR ,
most specifically files matching wildcard
.Ev PATCH_LIST .
Matching files are regenerated on the basis of
.Pp
.Dl $ diff -u -p -a ${DIFF_ARGS} $file$PATCHORIG $file
.Pp
and compared.
Modified patches are updated and reported, new patches are generated,
and old patches that no longer seem to exist are also reported.
.Pp
As an exception, if a
.Pa $file.beforesubst
original file is found, it is used instead of $file in the diff line:
.Pp
.Dl $ diff -u -p -a ${DIFF_ARGS} $file$PATCHORIG $file.beforesubst
.Pp
The patch header is normalized to always be:
.Bd -literal -offset indent
Index: $file
--- $file.orig
+++ $file
.Ed
.Pp
Patches with problematic
.Xr cvs 1
keywords may be fixed if possible, and reported if not.
.Pp
.Nm
prints the list of changed patches for further study.
.Sh ENVIRONMENT
.Bl -tag -width FORCE_REGEN
.It Ev DIFF_ARGS
Extra parameters to insert into
.Xr diff 1 .
.It Ev DISTORIG
Extension to original files to ignore entirely.
.It Ev FORCE_REGEN
Force patches to be regenerated even if they didn't change.
.It Ev PATCHDIR
Path to existing and generated patches.
.It Ev PATCHORIG
Extension to match for finding original files.
.It Ev PATCH_LIST
Only compare new patches to existing patches matching that pattern.
.It Ev PATCH_VERBOSE
Force
.Nm
to tell about everything it does.
.It Ev WRKDIST
Directory to scan for files to compare.
.El
.Sh SEE ALSO
.Xr cvs 1 ,
.Xr diff 1 ,
.Xr patch 1
